/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import entidade.Administrador;
import entidade.Aluno;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author master
 */
@Stateless
public class AlunoFacade extends AbstractFacade<Aluno> {
    @PersistenceContext(unitName = "AvaliacaoWebPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public AlunoFacade() {
        super(Aluno.class);
    }   
   
       
    public Aluno retornarAluno(String login){
        
        String sql = "select id from aluno where nome='" + login + "'";
        Query query = em.createNativeQuery(sql);
        Integer resultadoTemp = (Integer) query.getResultList().get(0);
        Aluno temp = null;
        if(resultadoTemp != null)
            temp = find(resultadoTemp);
        
        return temp;
    }
    
    
}
